package com.team20.map_demo.service;

import com.team20.map_demo.domain.User;
import com.team20.map_demo.mapper.UserMapper;
import io.micrometer.core.instrument.util.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UserServiceImpl implements UserService {
    @Autowired
    private UserMapper userMapper;

    /*@Override
    public User getUserByNameAndPwd(String userName, String userPassword) {
        return userMapper.selectByNameAndPwd(userName, userPassword);
    }*/

    @Override
    public int saveUser(User user) {
        if(StringUtils.isNotBlank(user.getId()))
            return userMapper.updateByPrimaryKey(user);
        else
            return userMapper.insert(user);
    }

    @Override
    public User findUserByName(String userName) {
        return userMapper.selectByName(userName);
    }
    public User findUserById(String userId){return userMapper.selectByPrimaryKey(userId);}
}
